package com.controller;


import com.domain.Account;
import com.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;


@Controller
@RequestMapping("/account")
public class AccountController {

   @Autowired
    private AccountService accountService;

    @RequestMapping(value = "/save", produces = "text/html;charset=UTF-8")
    @ResponseBody
     public ModelAndView save(Account account){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("login",accountService.save(account));
        modelAndView.setViewName("login");
        return modelAndView;
    }
    @RequestMapping("/findAll")
    public ModelAndView findAll() {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("login",accountService.findAll());
        modelAndView.setViewName("login");
        return modelAndView;
    }


}
